package com.example.androidtraining_ahut2020;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.Button;
import android.widget.GridLayout;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivityDay10DynamicLayout extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_day10_dynamic_layout);
        GridLayout layout = findViewById(R.id.GridLayout1);

        layout.setColumnCount(8);
        layout.setRowCount(8);
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++) {
                Button btn = new Button(this);
                if ((i + j) % 2 == 0)
                    btn.setBackgroundColor(Color.BLACK);
                else
                    btn.setBackgroundColor(Color.WHITE);
                layout.addView(btn, 100, 100);


            }


        }
    }
}